﻿//*************************************************************************
//面向服务的协作式智能交通系统仿真软件SoC-ITSS v2.1 alpha
//发布单位：西北工业大学--巴黎高科MINES机器人与群智能系统联合实验室
//团队负责人：张凯龙 Zhang Kailong
//团队成员：张大方、杨安胜、王敏、谢策、王雨佳、谢尘玉等
//联系我们：kl.zhang@nwpu.edu.cn
//2012-2021
//*************************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using CyberCarSimulation.Regulation;
using CyberCarSimulation.Bean;

//*******************************************************
//
//文件名(File Name):           Lane.cs
//
//数据表(Tables):              nothing 
//
//          修改理由：         定义属性
//
//*******************************************************
namespace CyberCarSimulation.RoadModel
{
    class Lane
    {
        private string ID;                      //车路ID
        private string WayID;                   //车道所属道路的ID
        private int Angle;                      //车道与水平线夹角
        private PointF StartPoint1;             //车道起始处两个顶点坐标1
        private PointF StartPoint2;             //车道起始处两个顶点坐标2
        private PointF EndPoint1;               //车道终止处两个顶点坐标1
        private PointF EndPoint2;               //车道终止处两个顶点坐标2
        private PointF ReservationLine;         //车道预约线坐标
        private PointF BrakeLine;               //车道刹车线坐标
        private float Length;                   //车道长度
        private float Width;                    //车道宽度
        private double Weight;                  //车道权值
        private double MaxLoad;                 //车道最大负载能力   
        private double UnobstructedTime;        //没有拥堵情况下，车辆通行时间
        private string StartCriticalID;         //车道起始临界区
        private string EndCriticalID;           //车道终止临界区
        private string LType;                   //车道类型 进入车道Enter 离开车道Leave 中间车道Center


        private List<string> PassedList = new List<string>();       //离开该车道的车辆
        private List<Vehicle> VehicleList = new List<Vehicle>();      //每一条车道都有一个List存储在其中的车辆序列
        private Queue<Vehicle> VehicleQueue = new Queue<Vehicle>();    //每一个车道Queue存放生成的车辆流


        private string EnterCEIntID;            //车道进入那个中间路口
        private string LeaveCEIntID;            //车道离开那个中间路口

        //无参构造函数
        public Lane()
        { 
        }

        //有参构造函数
        public Lane(string ID,string WayID,float Length,float Width,int Angle,
                    PointF StartPoint1, PointF StartPoint2, PointF EndPoint1,
                    PointF EndPoint2, PointF ReservationLine,PointF BrakeLine,
                    string StartCriticalID,string EndCriticalID,string LType) 
        { 
            this.ID = ID;
            this.WayID = WayID;
            this.Length = Length;   
            this.Width = Width;
            this.Angle = Angle;
            this.StartPoint1 = StartPoint1;
            this.StartPoint2 = StartPoint2;
            this.EndPoint1 = EndPoint1;
            this.EndPoint2 = EndPoint2;
            this.ReservationLine = ReservationLine;   
            this.BrakeLine = BrakeLine;        
            this.StartCriticalID = StartCriticalID;  
            this.EndCriticalID = EndCriticalID;
            this.LType = LType;
        }

        //获取车道ID
        public string GetID() 
        {
            return this.ID;
        }

        //设置车道ID
        public void SetID(String ID)
        {
            this.ID = ID;
        }

        //获取车道所属道路的ID
        public string GetWayID()
        {
            return this.WayID;
        }

        //设置车道所属道路的ID
        public void SetWayID(string WayID)
        {
            this.WayID = WayID;
        }

        //获取车道宽度
        public float GetWidth()
        {
            return this.Width;
        }

        //设置车道宽度
        public void SetWidth(float Width)
        {
            this.Width = Width;
        }

        //获取车道长度
        public float GetLength()
        {
            return this.Length;
        }

        //设置车道长度
        public void SetLength(float Length)
        {
            this.Length = Length;
        }

        //获取车道与水平线夹角
        public int GetAngle() 
        {
            return this.Angle;
        }

        //设置车道与水平线夹角
        public void SetAngle(int Angle)
        {
            this.Angle = Angle;
        }

        //获取车道起始处顶点坐标1
        public PointF GetStartPoint1() 
        {
            return this.StartPoint1;
        }

        //设置车道起始处顶点坐标1
        public void SetStartPoint1(PointF StartPoint1)
        {
            this.StartPoint1 = StartPoint1;
        }

        //获取车道起始处顶点坐标2
        public PointF GetStartPoint2( )
        {
            return this.StartPoint2;
        }

        //设置车道起始处顶点坐标2
        public void SetStartPoint2(PointF StartPoint2)
        {
            this.StartPoint2 = StartPoint2;
        }

        //获取车道终止处顶点坐标1
        public PointF GetEndPoint1()
        {
            return this.EndPoint1;
        }

        //设置车道终止处顶点坐标1
        public void SetEndPoint1(PointF EndPoint1)
        {
            this.EndPoint1 = EndPoint1;
        }  

        //获取车道终止处顶点坐标2
        public PointF GetEndPoint2()
        {
            return this.EndPoint2;
        }

        //设置车道终止处顶点坐标2
        public void SetEndPoint2(PointF EndPoint2)
        {
            this.EndPoint2 = EndPoint2;
        }

        //获取预约线位置
        public PointF GetReservationLine() 
        {
            return this.ReservationLine;
        }

        //设置预约线位置
        public void SetReservationLine(PointF ReservationLine)
        {
            this.ReservationLine = ReservationLine; 
        }

        //获取刹车线位置
        public PointF GetBrakeLine()
        {
            return this.BrakeLine;
        }

        //设置刹车线位置
        public void SetBrakeLine(PointF BrakeLine)
        {
            this.BrakeLine = BrakeLine;
        }

        //获取起始临界区ID
        public string GetStartCriticalID() 
        {
            return this.StartCriticalID;
        }

        //设置起始临界区ID
        public void SetStartCriticalID(string StartCriticalID)
        {
            this.StartCriticalID = StartCriticalID;
        }

        //获取终止临界区ID
        public string GetEndCriticalID()
        {
            return this.EndCriticalID;
        }

        //设置终止临界区ID
        public void SetEndCriticalID(string EndCriticalID)
        {
            this.EndCriticalID = EndCriticalID;
        }

        //获取车道类型
        public string GetLType()
        {
            return this.LType;
        }

        //设置道路类型
        public void SetLType(string LType)
        {
            this.LType = LType;
        }

        //获取离开车道的车辆List
        public List<string> GetPassedList()
        {
            return this.PassedList;
        }

        //设置离开车道的车辆队列List
        public void SetPassedList(List<string> PassedList)
        {
            this.PassedList = PassedList;
        }

        //获取该车道的车辆List
        public List<Vehicle> GetVehicleList()
        {
            return this.VehicleList;
        }

        //设置该车道上的车辆集合
        public void SetVehicleList(List<Vehicle> VehicleList)
        {
            this.VehicleList = VehicleList;
        }

        //获取该车道的车辆生成的车流量Queue
        public Queue<Vehicle> GetVehicleQueue()
        {
            return this.VehicleQueue;
        }

        //设置该车道的车流量Queue
        public void SetVehicleQueue(Queue<Vehicle> VehicleQueue)
        {
            this.VehicleQueue = VehicleQueue;
        }


        //获取车道的进入的中间路口节点的ID
        public string GetEnterCEIntID()
        {
            return this.EnterCEIntID;
        }
        //获取车道的进入的中间路口节点的ID
        public void SetEnterCEIntID(string EnterCEIntID)
        {
            this.EnterCEIntID = EnterCEIntID;
        }

        //获取车道的离开的中间路口节点的ID
        public string GetLeaveCEIntID()
        {
            return this.LeaveCEIntID;
        }
        //获取车道的离开的中间路口节点的ID
        public void SetLeaveCEIntID(string LeaveCEIntID)
        {
            this.LeaveCEIntID = LeaveCEIntID;
        }

        //获取车道权值
        public double GetWeight()
        {
            return this.Weight;
        }

        //设置车道权值
        public void SetWeight(double Weight)                   
        {
            this.Weight = Weight;
        }

        //获取车道最大负载
        public double GetMaxLoad() 
        {
            return this.MaxLoad;
        }

        //设置车道最大负载
        public void SetMaxLoad(double MaxLoad) 
        {
            this.MaxLoad = MaxLoad;
        }

        //获取UnobstructedTime
        public double GetUnobstructedTime()
        {
            return this.UnobstructedTime;
        }

        //设置UnobstructedTime
        public void SetUnobstructedTime(double UnobstructedTime) 
        {
            this.UnobstructedTime = UnobstructedTime;
        }

        //根据ID寻找对应的Intersection
        public static Lane FindLaneByID(string ID)
        {
            Lane lane = new Lane();
            foreach (Lane l in MainData.TotalLaneList)
            {
                if (l.GetID().Equals(ID))
                {
                    lane = l;
                }
            }
            return lane;
        }

    }
}
